package com.jiot.controller.project;

import com.zg.cloud.BaseResponse;
import com.zg.cloud.annotation.RoleCheck;
import com.zg.cloud.annotation.TokenCheck;
import com.zg.cloud.service.ProjectAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zg.cloud.CommonEnum.Role;
import req.admin.project.GetProjectListReq;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author liling
 * @date 2020/11/18 14:26
 * @description
 **/
@RestController
@RequestMapping("/device/project/admin")
@Api(value = "管理端项目模块")
public class ProjectAdminController {

    @Resource
    private ProjectAdminService projectAdminService;

    @RoleCheck({Role.SYS_ADMIN, Role.ADMIN, Role.PROVINCE_ADMIN, Role.CITY_ADMIN, Role.DISTRICT_ADMIN})
    @PostMapping("/count")
    @TokenCheck
    @ApiOperation(value = "获取项目数量", notes = "project")
    public BaseResponse count() {
        return new BaseResponse(projectAdminService.count());
    }

    @RoleCheck({Role.SYS_ADMIN, Role.ADMIN, Role.PROVINCE_ADMIN, Role.CITY_ADMIN, Role.DISTRICT_ADMIN})
    @PostMapping("/list")
    @TokenCheck
    @ApiOperation(value = "获取项目列表", notes = "project")
    public BaseResponse list(@RequestBody @Valid GetProjectListReq getProjectListReq) {
        return new BaseResponse(projectAdminService.list(getProjectListReq));
    }

    public BaseResponse add() {
        return new BaseResponse();
    }

    public BaseResponse delete() {
        return new BaseResponse();
    }
}
